const secret = "heweidong1998@163.com";
var jwt = require("jsonwebtoken");

//生成token
const util = {
    createToken: (info) => {
        let token = jwt.sign(info, secret, {
            //Token有效时间 单位s
            expiresIn: 60 * 60 * 240,
        });
        return token;
    },
    //验证Token
    verifyToken: (token) => {
        try {
            let result = jwt.verify(token, secret) || {};
            return result;
        } catch (err) {
            return false;
        }
    },
};
module.exports = util;
